package com.tiantian.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.tiantian.dao.OrderWhisperRelationshipRepository;
import com.tiantian.datajpa.service.impl.GenericServiceImpl;
import com.tiantian.domain.Orderwhisperrelationship;
import com.tiantian.service.OrderWhisperRelationshipService;

@Service
@Transactional
public class OrderWhisperRelationshipServiceImpl extends GenericServiceImpl<Orderwhisperrelationship, String> implements
		OrderWhisperRelationshipService {
	private OrderWhisperRelationshipRepository repository;

	@Autowired
	public void setRepository(OrderWhisperRelationshipRepository repository) {
		super.setGenericDAO(repository);
		this.repository = repository;
	}

	public Orderwhisperrelationship getByOrderId(String orderId) {
		String sql = "select * from Orderwhisperrelationship where orderId=:orderId";
		Map<String, Object> param = new HashMap<>();
		param.put("orderId", orderId);
		List<Orderwhisperrelationship> list = this.repository.queryListBySql(sql, param, Orderwhisperrelationship.class);
		if (list != null && list.size() > 0)
			return list.get(0);
		return null;
	}

}
